package com.weiyan.config;

import com.alibaba.csp.sentinel.slots.block.BlockException;
import com.alibaba.csp.sentinel.slots.block.degrade.DegradeException;
import com.alibaba.csp.sentinel.slots.block.flow.FlowException;
import lombok.extern.slf4j.Slf4j;

/**
 * @author misterWei
 * @create 2020年02月25号:22点32分
 * @mailbox mynameisweiyan@gmail.com
 */
@Slf4j
public class BlockHandler {

    // 必须是静态方法,
    public static void message(BlockException e) {
        ResponseData data = null;
        if (e instanceof FlowException) {
            data = new ResponseData(-1, "接口被限流了...");
        } else if (e instanceof DegradeException) {
            data = new ResponseData(-2, "接口被降级了...");
        }
        log.error("{}",data);
    }
}

